<?php
$dbcnx = mysqli_connect("216.185.102.20", "darylho", "8604923?", "mobile_loan_application");
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$loan_id = $_POST['loanid'];

//get customer personal detail
if ($result2 = $dbcnx -> query("SELECT customer_title, customer_given_name, customer_surname,customer_number 
                            FROM `customer` WHERE `customer_id`='$loan_id'")) {
    while ($obj2 = mysqli_fetch_array($result2)) {
        extract($obj2);
        print("$customer_title:");
        print("$customer_given_name:");
        print("$customer_surname:");
        print("$customer_number:");
        
    }

//get customer salary
if ($result3 = $dbcnx -> query("SELECT salary 
                            FROM `gross_income` WHERE `customer_id`='$loan_id'")) {
    while ($obj3 = mysqli_fetch_array($result3)) {
        extract($obj3);
        print("$salary:");
        
    }


//get customer monthly repayment amount
if ($result4 = $dbcnx -> query("SELECT home_loan, other_loan, credit_card, store_card, vehicle_finance, personal_loan, rent, expenses_other_amount
                            FROM `expenses` WHERE `customer_id`='$loan_id'")) {
    while ($obj4 = mysqli_fetch_array($result4)) {
        extract($obj4);
        print("$home_loan:");
        print("$other_loan:");
        print("$credit_card:");
        print("$store_card:");
        print("$vehicle_finance:");
        print("$personal_loan:");
        print("$rent:");
        print("$expenses_other_amount:");
        
    }
}
    mysqli_close($dbcnx);
}
}
?>